package cn.hxth.cloud;

import org.apache.ibatis.session.SqlSession;
import tk.mybatis.mapper.mapperhelper.MapperHelper;

import java.util.Date;

public class MyTest {
    public static void main(String[] args) {
        /*SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder() ;
        InputStream inputStream = MyTest.class.getClassLoader().getResourceAsStream("mybatis.cfg.xml");
        SqlSessionFactory sessionFactory = builder.build(inputStream);*/
        SqlSession session = MyBatisSessionFactory.getSession() ;
//创建一个MapperHelper
        MapperHelper mapperHelper = new MapperHelper();
        // mapperHelper.registerMapper(Mapper.class);
        mapperHelper.processConfiguration(session.getConfiguration());
     UserMapper userMapper = session.getMapper(UserMapper.class);
        UserDO user = new UserDO() ;
        user.setAge(11);
        user.setName("xia");
        user.setDate(new Date());
        System.out.println(userMapper.insert(user));
        System.out.println(
                MyBatisSessionFactory.getSession()== session
        );;
        System.out.println(user.getId());
    }
}
